package org.bai.algorithm.day03;

/**
 * @ClassName ReverseLeftWords
 * @Description <a href="https://leetcode-cn.com/problems/zuo-xuan-zhuan-zi-fu-chuan-lcof/">左旋转字符串</a>
 * @Author bai
 * @Date 2021/8/12 0:32
 * @Version 1.0
 **/
public class ReverseLeftWords {

    public static String reverseLeftWords(String s, int n) {
        if (n < 1 || n > s.length()) {
            return null;
        }

        String anteriorSegment = s.substring(0, n);
        String backSection = s.substring(n);

        return backSection + anteriorSegment;
    }

    public static void main(String[] args) {
        String s = "abcdefg";
        System.out.println(reverseLeftWords(s, 2));
    }
}
